package com.mall4j.cloud.user.interfaces;

import com.mall4j.cloud.base.model.BaseResult;
import com.mall4j.cloud.user.application.model.UserVo;
import com.mall4j.cloud.user.application.model.cmd.RegisterCmd;
import com.mall4j.cloud.user.application.service.UserAppService;
import com.mall4j.cloud.user.infrastructure.persist.dao.UserMapper;
import com.mall4j.cloud.user.infrastructure.persist.po.UserPo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@Tag(name = "C端用户", description = "C端登录用户")
@RestController
public class UserController {

    @Resource
    UserMapper userMapper;

    @Resource
    UserAppService userAppService;

    @Operation(summary = "用户注册", description = "用户注册")
    @PostMapping("/users")
    public BaseResult<UserVo> register(@RequestBody RegisterCmd registerCmd) {
        userAppService.register(registerCmd);
        return BaseResult.success(null);
    }

    @Operation(summary = "列新用户信息", description = "用户注册")
    @PostMapping("/modify")
    public BaseResult<UserVo> modify() {
        return BaseResult.success(null);
    }

    @Operation(summary = "查询用户信息详情")
    @GetMapping("/detail/{id}")
    public BaseResult<UserPo> detail(@PathVariable("id") Long id) {
        UserPo result = userMapper.selectById(id);
        return BaseResult.success(result);
    }
}
